﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.EntityFrameworkCore;

using Xc.DataAccess.DataBase.DeviceInfos;
using Xc.DataAccess.DataBase.DeviceInfos.Models;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class ApplicationDbContextExtension
    {
        /// <summary>
        /// 添加设备信息管理服务
        /// <list type="number">
        /// <item>设备信息服务 <see cref="IDbDeviceInfoService"/></item>
        /// </list>
        /// </summary>
        /// <typeparam name="TDbContext"></typeparam>
        /// <param name="serviceDescriptors"></param>
        /// <returns></returns>
        public static IServiceCollection AddDbDeviceInfoService<TDbContext>(this IServiceCollection serviceDescriptors) where TDbContext: DbContext, IDbDeviceInfo
        {
            serviceDescriptors.AddAutoMapper<MapperProfile>();
            serviceDescriptors.AddTransient<IDbDeviceInfoPropertyService, DbDeviceInfoPropertyService<TDbContext>>();
            serviceDescriptors.AddTransient<IDbCommandInfoService, DbCommandInfoService<TDbContext>>();
            serviceDescriptors.AddTransient<IDbDeviceInfoService, DbDeviceInfoService<TDbContext>>();
            return serviceDescriptors;
        }
    }
}
